package com.atguigu.gmall.all.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.order.client.OrderFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Map;

/**
 * @author mgx
 * @version 1.0
 * @description: TODO
 * @date 2022-12-10 13:10
 */
@Controller
@SuppressWarnings("all")
public class OrderController {

    @Autowired
    private OrderFeignClient orderFeignClient;

    /**
     * http://order.gmall.com/myOrder.html
     * 跳转我的订单页面
     * @return
     */
    @GetMapping("/myOrder.html")
    public String myOrder() {
        return "order/myOrder";
    }

    /**
     * http://order.gmall.com/trade.html
     * 跳转结算页面
     * @return
     */
    @GetMapping("/trade.html")
    public String trade(Model model) {
        // 远程调用获取信息
        Result<Map<String, Object>> result = orderFeignClient.trade();
        model.addAllAttributes(result.getData());
        return "order/trade";
    }
}
